Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retry-request

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retry-request

Retry a request.

  • 5.0.2
  • legacy-12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.4M
increased by6.07%
Maintainers
2
Weekly downloads
 
Created

What is retry-request?

The retry-request npm package is designed to make it easier to handle network requests that might need to be retried due to failures or errors. It wraps around the standard request functionality, providing a way to automatically retry requests a specified number of times, with customizable intervals between retries. This is particularly useful in environments where network reliability can't always be guaranteed, or when dealing with services that might occasionally fail or be temporarily unavailable.

What are retry-request's main functionalities?

Basic retry functionality

This demonstrates how to use retry-request to make a simple HTTP request with retry functionality. If the request fails, retry-request will automatically retry the request based on its default configuration.

const retryRequest = require('retry-request');

const requestOptions = {
  url: 'http://example.com'
};

retryRequest(requestOptions, function(err, response, body) {
  if (!err) {
    console.log(body);
  }
});

Custom retry options

This example shows how to customize the retry behavior, including the number of retries, the delay between retries, and even specifying a custom request module to use for the actual HTTP requests.

const retryRequest = require('retry-request');

const requestOptions = {
  url: 'http://example.com'
};

const options = {
  retries: 5,
  request: require('request'),
  retryDelay: 1000
};

retryRequest(requestOptions, options, function(err, response, body) {
  if (!err) {
    console.log(body);
  }
});

Other packages similar to retry-request

Keywords

FAQs

Package last updated on 14 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc